﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using System.Data.Entity.ModelConfiguration;

namespace Business.Models
{
    public class GiaoVien_LopHoc
    {
        [Key]
        public int IdGiaoVien_LopHoc { get; set; }
        //public int GiaoVien { get; set; }
        public virtual GiaoVien GiaoVien { get; set; }
        //public int LopHoc { get; set; }
        public virtual LopHoc LopHoc { get; set; }
        public bool HoatDong { get; set; }
    }

    public class GiaoVien_LopHocConfiguration : EntityTypeConfiguration<GiaoVien_LopHoc>
    {

        public GiaoVien_LopHocConfiguration()
            : base()
        {

            HasKey(d => d.IdGiaoVien_LopHoc);
            Property(d => d.IdGiaoVien_LopHoc).
                HasColumnName("IdGiaoVien_LopHoc").
                HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity).
                IsRequired();
            HasRequired(x => x.GiaoVien).
            WithMany().
                Map(x => x.MapKey("GiaoVien"));

            HasRequired(x => x.LopHoc).
            WithMany().
                Map(x => x.MapKey("LopHoc"));

            Property(d => d.HoatDong).
                HasColumnName("HoatDong").
                IsRequired();
            
            ToTable("GiaoVien_LopHoc", "dbo");
        }

    }
}